<?php
namespace app\yhUtil\type;


class Image extends Base {
    protected $contentType = 'image';

    protected $content = [];

    public function __construct(string $file, $message = []){
        parent::__construct($message);
        $this->setImage($file);
    }
    
    public function setImage(string $imagePath){
        $fileResponse = $this->sendFile($imagePath);
        if($fileResponse['code']){
            $imageKey = $fileResponse['data']['imageKey'];
            return $this->setImageKey($imageKey);
        }
        throw new $fileResponse['msg'];
    }

    public function setImageKey($imageKey) {
        $this->content['imageKey'] = $imageKey;
        return $this;
    }
}